# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=xssless
pkgver=45.8e7ebe1
pkgrel=4
pkgdesc='An automated XSS payload generator written in python.'
url='https://github.com/mandatoryprogrammer/xssless'
groups=('blackarch' 'blackarch-webapp')
arch=('any')
license=('GPL2')
depends=('python2' 'python2-beautifulsoup4')
makedepends=('git')
source=('git+https://github.com/mandatoryprogrammer/xssless.git')
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  # TODO: fix this.
  grep -iRl 'python' "$srcdir/xssless" |
  xargs sed -i 's|#!.*/usr/bin/python|#!/usr/bin/python2|;s|#!.*/usr/bin/env python$|#!/usr/bin/env python2|'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python2 /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

